package com.example.friendcash.database.services.implementation;

import android.database.Cursor;
import com.example.friendcash.database.dao.interfaces.IDaoFactory;
import com.example.friendcash.database.dao.interfaces.IPartDao;
import com.example.friendcash.database.dao.interfaces.IPaymentDao;
import com.example.friendcash.database.services.interfaces.IPaymentService;

public class PaymentService extends Service implements IPaymentService {

    public PaymentService(IDaoFactory daoFactory) {
        super(daoFactory);
    }

    @Override
    public Cursor getAllPayments(long eventId) {
        final IPaymentDao paymentDao = daoFactory.createPaymentDao();
        return paymentDao.getAllPayments(eventId);
    }

    @Override
    public void deletePayment(long paymentId) {
        final IPaymentDao paymentDao = daoFactory.createPaymentDao();
        paymentDao.removePayment(paymentId);
        final IPartDao partDao = daoFactory.createPartDao();
        partDao.removePartsByPaymentId(paymentId);
    }
}
